<template>
  <el-dialog
    title="学生进度确认"
    :visible.sync="isShow"
    width="600px"
  >
    <span>是否保留以下学生《{{ courseName }}》历史学习记录？</span>
    <div class="studentList">
      <div v-for="(item,index) in recoverList">{{ item.name }}（{{ item.studentNum }}）<span v-if="index!= recoverList.length-1">；</span>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
    <el-button v-preventReClick @click="isShow = false">取 消</el-button>
    <el-button v-preventReClick type="primary" @click="SubmintDialog(0)">不保留并排课</el-button>
    <el-button v-preventReClick type="primary" @click="SubmintDialog(1)">保留并排课</el-button>
  </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'studyRecordConfirm',
  props: {
    courseName: {
      type: String,
      default: ''
    },
    recoverList: {
      type: Array,
      default: []
    },
    openType: {
      type: [String, Number],
      default: 1
    },
    type: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      isShow: false,
      params: {}
    }
  },
  methods: {
    show(params) {
      this.isShow = true
      this.params = params
    },
    SubmintDialog(recoverStudyRecord) {
      if (this.type == 'addStu') {
        this.$emit('AddStu', this.params.studentIds, recoverStudyRecord)
      } else {
        this.params.recoverStudyRecord = recoverStudyRecord
        if (this.openType == 2) {
          this.$emit('updateClass', this.params)
        } else {
          this.$emit('addClass', this.params)
        }
      }
      this.isShow = false
    }
  }
}

</script>
<style scoped lang="scss">
.studentList {
  height: 200px;
  border: 1px solid #ccc;
  overflow: auto;
  margin: 20px 0;
  padding: 15px;
  box-sizing: border-box;
}
</style>
